//
//  BRRequestManager.h
//  BrezzeSaaS
//
//  Created by IOS on 2021/9/1.
//  Copyright © 2021 Brezze GWG. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/*
 * 网络请求枚举类型
 */
typedef enum {
    GET,
    POST,
    PATCH,
    DELETE,
    PUT,
}REQUEST_TYPE;


/**
 成功的block
 @param dataDict 返回的数据
 @param respCode 返回的请求码
 */
typedef void(^SucceedBlock)(NSDictionary *dataDict, NSInteger respCode);

/**
 失败的block
 @param code 错误码
 @param errMsg 错误信息
 */
typedef void(^Failed)(NSInteger code,NSString *errMsg);


@interface BRRequestManager : NSObject


/*
 * 单例
 */
+ (instancetype)shared;

- (NSURLSessionDataTask *)POST:(NSString *)url params:(nullable NSDictionary *)params succeed:(SucceedBlock)succeed failed:(Failed)failed;

/// POST请求（表单格式，application/x-www-form-urlencoded）
- (NSURLSessionDataTask *)POSTWithFormData:(NSString *)url params:(nullable NSDictionary *)params succeed:(SucceedBlock)succeed failed:(Failed)failed;

- (NSURLSessionDataTask *)PUT:(NSString *)url params:(nullable NSDictionary *)params succeed:(SucceedBlock)succeed failed:(Failed)failed;

- (NSURLSessionDataTask *)GET:(NSString *)url params:(nullable NSDictionary *)params succeed:(SucceedBlock)succeed failed:(Failed)failed;

- (NSURLSessionDataTask *)DELETE:(NSString *)url params:(nullable NSDictionary *)params succeed:(SucceedBlock)succeed failed:(Failed)failed;

/// 监听网络状态切换
+ (void)AFNReachability;

@end

NS_ASSUME_NONNULL_END
